import React, {useState} from 'react';
import {Modal} from 'antd';
import rqsApi from './eventRqs';

export default function Index(props) {
  /**btnEvent 按钮事件
   * editdata 列表数据
   * visible 弹窗状态
   * closeModalFn 父组件关闭弹窗
   */
  const {btnEvent, editdata, visible, msg, closeModalFn} = props;
  const [confirmLoading, setConfirmLoading] = useState(false);
  console.log(props)
  const handleOk = () => {
    setConfirmLoading(true);
    rqsApi(btnEvent, editdata);
    setTimeout(() => {
      setConfirmLoading(false);
      closeModalFn(btnEvent);
    }, 500);


  };

  const handleCancel = () => {
    closeModalFn();
  };
  return (
    <Modal
      title="提示"
      transitionName=""
      maskTransitionName=""
      visible={visible}
      onOk={handleOk}
      confirmLoading={confirmLoading}
      onCancel={handleCancel}
    >
      <h2 style={{textAlign: 'center'}}>{msg}</h2>
    </Modal>
  );
}
